import Mock from 'mockjs'


var data1 = Mock.mock({
  // 20条数据
  "data|85": [{
    // // 商品种类
    // "goodsClass": "女装",
    // // 商品Id
    // "goodsId|+1": 1,
    // //商品名称
    // "goodsName": "@ctitle(10)",
    // //商品地址
    // "goodsAddress": "@county(true)",
    // //商品等级评价★
    // "goodsStar|1-5": "★",
    // //商品图片
    // "goodsImg": "@Image('100x100','@color','小甜甜')",
    // //商品售价
    // "goodsSale|30-500": 30
    "goodsId|+1":1,
    "goodTime":"@Date()",
    // "goodTimeOut":
    "goodName":'@cname',
    "goodAddress":'@county(true)',
    "goodNum|0-2000":432,
    "goodPrice":1323.22,
    "goodWay":'微信'
  }]
  

})


class NewData{
   getData(params){
     const {size = 13,current = 1,starTime,endTime} = params;
    //  console.log(current);
     let arr = [];
    let arr1=[];

     if(starTime){
        arr = data1.data.filter(el=>new Date(el.goodTime).getTime() > starTime &&  new Date(el.goodTime).getTime() < endTime )
       arr1 =  arr.slice((current -1)*size,current*size)
       return new Promise((resolve)=>{
        resolve({
         status:0,
         list:arr1,
         count:arr.length
        })
        })
     }else{
    const  result = data1.data.slice((current-1)*size,current*size )
      return new Promise((resolve)=>{
        resolve({
         status:0,
         list:result,
         count:data1.data.length
        })
 })
     }
         
    
  
   }

   removeData(params){
    for(let i =0;i <params.arr3.length;i++){
    data1.data = data1.data.filter(el=>{
        return el.goodsId !== params.arr3[i]
      })
    }
    console.log("data1.data",data1.data);
   
     
   }
}

const datas = new NewData()
export default datas
